package com.xlt.activiti.search;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

public class ActivitiTaskSearch {

    public static void taskSearch(String key,String userId){
        // 1.得到processEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 2.得到RunTimeService TaskService
        RuntimeService runtimeService = processEngine.getRuntimeService();
        TaskService taskService = processEngine.getTaskService();

        // 3.查询服务
        Task task = taskService.createTaskQuery().processDefinitionKey(key).taskAssignee(userId).singleResult();
        String processInstanceId = task.getProcessInstanceId();

        ProcessInstance processInstance = runtimeService.
                createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();

        String businessID = processInstance.getBusinessKey();

        // 查询业务数据库 -- 查询流程清单
    }
}
